package com.szt.school.controller;


import com.szt.school.pojo.User;
import com.szt.school.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.sql.DataSource;

@RestController //如果你只需要返回字符串
//@Controller //如果你需要返回的是个页面
public class HelloController {
    @Autowired
    DataSource dataSource;
    @Autowired
    UserService userService;
    @GetMapping("hello")
    public String hello(){

        return "hello,springboot;dataSource:"+dataSource ;
    }
    @GetMapping("/user/{id}")
    public User queryById(@PathVariable Long id){
        return userService.queryById(id);
    }
}
